The present invention relates generally to data communications. More particularly, the present invention relates to checksum calculation for data packets to be transmitted over a communication network.
Packet switching is a widely-used technique for transmitting data over a communications network, which can be electronic, optical, wireless and the like. A file of data to be transmitted across the network is first broken into portions referred to as packets. A header is added to each packet. The header includes parameters describing the packet, such as its size, and delivery information, such as the source and destination addresses of the packet. The packets are sent over the network, and after arriving at the destination, are reassembled to recreate the data file.
However, during transmission over the network, the contents of a packet may become corrupted. One method for detecting such errors is checksumming. According to this method, some or all of the bits in the packet are combined, for example by one's-complement addition, prior to transmission to produce a checksum, which is then written to a field in a header or trailer of the packet. At the destination, the same checksum method is applied to the received packet to independently calculate a checksum. If the checksum in the packet header and the checksum calculated at the destination are not the same, the packet was corrupted during transmission.
In general, data is transmitted between network devices that can be implemented as personal computers, cellular telephones, personal digital assistants, and the like, and that each comprise a processor, such as a central processing unit, and a network interface controller, such as a network interface card. In many conventional implementations, the checksum is calculated by processor. However, according to a method referred to as “checksum offload,” the checksum can be calculated by some device other than the processor, such as the network interface controller.
When a transport-layer packet is large, the network-layer module of the protocol stack breaks the transport-layer packet into two or more fragments before sending the transport-layer packet to the network. For example, in a User Datagram Protocol/Internet Protocol (UDP/IP) protocol stack, when the size of a UDP packet exceeds the Maximum Transmission Unit (MTU) size of the network, the IP module of the protocol stack fragments the UDP packet, thereby generating multiple IP packets, which are referred to as fragments of the UDP packet. One of the fragments contains a portion of the payload of the UDP packet and the header of the UDP packet. The header contains a field for the checksum.
Conventional network interface controllers are unable to perform checksum offload for such fragmented packets. Therefore, checksums for fragmented packets are conventionally performed by the processor in the protocol stack or device driver, with the consequent loss of the advantages of checksum offload.